package com.wyg.blog.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyg.blog.mapper.BlogTagMapper;
import com.wyg.blog.model.blog.BlogTag;
import com.wyg.blog.service.blog.BlogTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: WYG
 * @time: 2020/7/2 21:18
 */
@Service
public class BlogTagServiceImpl implements BlogTagService {
    @Autowired
    BlogTagMapper blogTagMapper;

    @Override
    public IPage<BlogTag> selectBlogTags(Page<?> page) {
        return blogTagMapper.getBlogTags(page);
    }

    @Override
    public List<Integer> selectTagIdByBid(Integer bid) {
        return blogTagMapper.getTagIdByBid(bid);
    }

    @Override
    public Integer selectBlogCount(Integer tid) {
        return blogTagMapper.getBlogCount(tid);
    }

    @Override
    public IPage<Integer> selectBlogIdByTid(Page<?> page, Integer tid) {
        return blogTagMapper.getBlogIdByTid(page, tid);
    }

    @Override
    public boolean insertBlogTag(List<BlogTag> blogTags) {
        return blogTagMapper.addBlogTag(blogTags);
    }

    @Override
    public boolean removeBlogTagByBid(Integer bid) {
        return blogTagMapper.deleteBlogTagByBid(bid);
    }

    @Override
    public boolean removeBlogTagByTid(Integer tid) {
        return blogTagMapper.deleteBlogTagByTid(tid);
    }

    @Override
    public boolean isContains(Integer bid, Integer tid) {
        return blogTagMapper.contains(bid, tid) != 0;
    }
}
